﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using HRC.Library.ContextFoundation;
using Lehnet.BusinessLayer;
using Lehnet.BusinessLayer.Interfaces;
using Lehnet.Models;
using Lehnet.WebUI.Helpers;

namespace Lehnet.WebUI.Controllers
{
    public class AccountController : Controller
    {
        //
        // GET: /Account/

        public ActionResult Login()
        {
            return View();
        }

        public ActionResult PersonelLogin()
        {
            return View(new Personel());
        }
        [HttpPost]
        public ActionResult PersonelLogin(Personel personel)
        {
            var pb = ProxyHelper<PersonelBusiness, IPersonelBusiness>.Instance.AddOrGet();
            personel = pb.Login(personel);
            if(personel.Id != 0)
            {
                SessionHelper.Personel = personel;
                return RedirectToAction("Index", "Home");
                
            }
            ViewBag.Message = "Kullanıcı adı veya şifre hatalı.";
            return View();
        }

        public ActionResult MusteriPersonelLogin()
        {
            return View(new MusteriPersonel());
        }
        [HttpPost]
        public ActionResult MusteriPersonelLogin(MusteriPersonel musteriPersonel)
        {
            var mb = ProxyHelper<MusteriPersonelBusiness, IMusteriPersonelBusiness>.Instance.AddOrGet();
            musteriPersonel = mb.Login(musteriPersonel);
            if (musteriPersonel.Id != 0)
            {
                SessionHelper.MusteriPersoneli = musteriPersonel;
                return RedirectToAction("Index", "Home");
            }
            ViewBag.Message = "Kullanıcı adı veya şifre hatalı.";
            return View();
        }
    }
}
